import instance from "../utils/request";

export async function uploadImageBase64(key, base64Image){
    try {
        const res = await instance({
            url: '/Image/upload/base64',
            method: 'post',
            params: {
                key: key,
                base64Image: base64Image
            }
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function downloadImage(imageKey){
    try {
        const res = await instance({
            url: `/Image/download/${imageKey}`,
            method: 'get',
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function deleteImage(imageKey){
    try {
        const res = await instance({
            url: `/Image/delete/${imageKey}`,
            method: 'delete',
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function uploadImageFile(key, imageFile){
    try {
        const res = await instance({
            url: '/Image/upload/file',
            method: 'post',
            params: {
                key: key,
            },
            data: imageFile
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}